<!DOCTYPE html>
<html>
<head>
	<title>react-form</title>
    <meta charset="UTF-8" />
	<script src='../node_modules/react/umd/react.development.js'></script>
	<script src='../node_modules/react-dom/umd/react-dom.development.js'></script>
    <script src='../node_modules/babel-standalone/babel.min.js'></script>
    
</head>
<body>
    <div id="my"></div>
    <script type="text/babel">
    class Hello extends React.Component{
        constructor(){
            super();
            this.state = {
                name:'',
                password:'',
                address:''
            };
        };
        handleChange(e){
            var name = e.target.name;
            this.setState({
                [name]:e.target.value 
            })
        };
     
        submit() {
            alert(JSON.stringify(this.state))
        }
        
        render(){ 
            return (
                <div>
                    <p>
                        <label>姓名：</label>
                        <input type="text"
                          name='name'
                          value={this.state.name} 
                          onChange={(e)=>this.handleChange(e)}/>
                    </p>
                     <p>
                        <label>密码：</label>
                        <input type="password" 
                            name='password'
                            value={this.state.password} 
                            onChange={(e)=>this.handleChange(e)}/>
                    </p>
                     <p>
                        <label>地址：</label>
                        <input type="text" 
                            name='address'
                            value={this.state.address} 
                            onChange={(e)=>this.handleChange(e)}/>
                    </p>
                    <p>
                        <button onClick={()=>this.submit()}>提交</button>
                    </p>
                </div>
                )
        }
    };
    
     ReactDOM.render(
          <Hello/>,
        document.getElementById('my')
    )
    </script>
</body>
</html>